(function($) {
	"use strict";
	
	var loginBtn = "#loginBtn", forgetBtn = "#forgetBtn", registerBtn = "#registerBtn", $msg = $('#msg') ;
	
	$(function() {
		
		$(loginBtn).on("click", function() {
			var formData = $("form#login").serializeArray() ;
			$.ajax({
				type: 'POST',
				url: "http://sso.mars.com/login",
				data: formData,
				crossDomain: true,
				xhrFields: {	//跨域凭证
					withCredentials: true
	            },
				beforeSend: function() {
				},
				success: function(result) {
					try {
						if(result.status) {
							$msg.html('<span style="color:green">'+result.message+'</span>');
							window.location.replace("/index.html");
						} else {
							$msg.html('<span style="color:red">'+result.message+'</span>');
						}
					} catch(e) {
						console.error(e) ;
					}
				},
				complete: function(xhr, textStatus) {
				}
			});
			
		});
		
	})
	
})(jQuery);